<?php

class Application_Form_AlteraCadastro extends Zend_Form
{
    protected $_nome;
    protected $_senha;
    protected $_novaSenha;
    protected $_confirmaSenha;


    public function init()
    {
        $this->setMethod('post');
        
        $this->addElement('text', 'nome', array(
            'label'      => 'Seu nome:',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(1, 60))
            )

        ));

        $this->_nome = $this->getElement('nome');

        $this->addElement('password', 'senha', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                'Alnum',
                array('StringLength', false, array(6, 20)),
            ),
            'required'   => true,
            'label'      => 'Senha atual:',
        ));

        $this->_senha = $this->getElement('senha');

       $this->addElement('password', 'nova_senha', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                'Alnum',
                array('StringLength', false, array(6, 20)),
            ),
            'required'   => false,
            'label'      => 'Nova senha:',
        ));

       $this->_novaSenha = $this->getElement('nova_senha');

       $this->addElement('password', 'confirma_senha', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                'Alnum',
                array('StringLength', false, array(6, 20)),
            ),
            'required'   => false,
            'label'      => 'Confirmar nova senha:',
        ));

       $this->_confirmaSenha = $this->getElement('confirma_senha');

        //botao de alterar dados
        $criar = $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Alterar',
        ));

        // alguma protecao contra flood.
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));

    }

    public function setNome($nome){
        $this->_nome->setValue($nome);
    }

}

